import { format } from 'date-fns';

declare const window: {
  electronAPI: {
    getUserSettings: () => Promise<{
      email: string;
      site: string;
    }>;
  };
};

export async function buildMonitoringData(params: {
  rpaId: string;
  rpaName: string;
  info: string;
  extra?: string;
}) {
  const userSettings = await window.electronAPI.getUserSettings();
  
  return [{
    user_name: userSettings.email.split('@')[0],
    user_location: userSettings.site,
    rpa_id: params.rpaId,
    rpa_name: params.rpaName,
    rpa_version: "1.0.0",
    occurrence: format(new Date().toUTCString(), "EEE, dd MMM yyyy HH:mm:ss"),
    info: params.info,
    extra: params.extra || ''
  }];
}
